<template name="message">
	<view class="index-message">
		<view class="big-title">
			<u-section title="业务咨询" :right="false"></u-section>
		</view>
		<view class="message-box">
			<form :model="form" ref="uForm" @submit="formSubmit">
				<input class="hidden-input" name="__formid__" value="5" />
				<input class="uni-input" name="name" placeholder-style="color:#c0c4cc;" placeholder="您的姓名(必填)"
					confirm-type="next" />
				<input class="uni-input" name="phone" placeholder-style="color:#c0c4cc;" placeholder="手机号码或者微信号码(必填)"
					confirm-type="next" />
				<textarea class="uni-textarea" name="desc" placeholder-style="color:#c0c4cc;"
					placeholder="请输入您要咨询的问题,或简单描述下您的项目需求(必填)" confirm-type="send" />
				<u-button class="submit" type="primary" form-type="submit">提交</u-button>
				<u-divider half-width="200" height="80">or</u-divider>
				<view class="mess-btn">
					<u-button class="submit" type="error" open-type="contact">在线咨询</u-button>
					<u-button class="submit" type="warning " @click="tocall">拨打电话</u-button>
				</view>
			</form>
		</view>

	</view>
</template>

<script>
	export default {
		name: "message",
		data() {
			return {
			};
		},
		onLoad: function(e) {
			// this.$u.api.getBlockTel({}).then(res => {
			// 	console.log(res.data);
			// 	this.teltel = res.data;
			// });
		},
		methods: {
			
			tocall() {
				this.$u.api.getBlockTel({}).then(res => {
					uni.makePhoneCall({
						phoneNumber: res.data
					});
				});
				
			},
			// 表单提交
			formSubmit: function(e) {
				var formdata = JSON.stringify(e.detail.value)
				var formdata = JSON.parse(formdata)
				console.log(e.detail.value.name)
				this.$u.api.getForm({
					__formid__: e.detail.value.__formid__,
					name: e.detail.value.name,
					phone: e.detail.value.phone,
					desc: e.detail.value.desc,
				}).then(res => {
					console.log(res.state)
					if (res.state == 200) {
						this.$refs.submitTips.show({
							title: '提交成功，我们会尽快与您联系',
							type: 'success',
							duration: '2300'
						})
					} else {
						this.$refs.submitTips.show({
							title: '提交失败，请完善信息或重新提交',
							type: 'error',
							duration: '2300'
						})
					}

				});

			},
		}
	}
</script>

<style>

</style>
